﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WhittleList.Bll;
using WhittleList.Tests.Mocks;

namespace WhittleList.Tests.Helpers
{
    public static class MockHelpers
    {
        public static System.Data.Linq.Binary CreateBinary(Random rnd)
        {
            byte[] bytes = new byte[8];
            for (int i = 0; i < bytes.Length; i++)
            {
                bytes[i] = System.Convert.ToByte(rnd.Next(0, 100));
            }
            return bytes;
        }

        public static IQueryable<User> Convert(this List<FakeUser> items)
        {
            return items != null ? items.AsQueryable().Convert() : null;
        }

        public static IQueryable<User> Convert(this IQueryable<FakeUser> items)
        {
            return items != null ? items.Select(x => x.Object) : null;
        }

        public static IQueryable<Site> Convert(this List<FakeSite> items)
        {
            return items != null ? items.AsQueryable().Convert() : null;
        }

        public static IQueryable<Site> Convert(this IQueryable<FakeSite> items)
        {
            return items != null ? items.Select(x => x.Object) : null;
        }

        public static IQueryable<Project> Convert(this List<FakeProject> items)
        {
            return items != null ? items.AsQueryable().Convert() : null;
        }

        public static IQueryable<Project> Convert(this IQueryable<FakeProject> items)
        {
            return items != null ? items.Select(x => x.Object) : null;
        }

        public static IQueryable<UserProjectRole> Convert(this List<FakeUserProjectRole> items)
        {
            return items != null ? items.AsQueryable().Convert() : null;
        }

        public static IQueryable<UserProjectRole> Convert(this IQueryable<FakeUserProjectRole> items)
        {
            return items != null ? items.Select(x => x.Object) : null;
        }

        public static IQueryable<Section> Convert(this List<FakeSection> items)
        {
            return items != null ? items.AsQueryable().Convert() : null;
        }

        public static IQueryable<Section> Convert(this IQueryable<FakeSection> items)
        {
            return items != null ? items.Select(x => x.Object) : null;
        }

        public static IQueryable<Item> Convert(this List<FakeItem> items)
        {
            return items != null ? items.AsQueryable().Convert() : null;
        }

        public static IQueryable<Item> Convert(this IQueryable<FakeItem> items)
        {
            return items != null ? items.Select(x => x.Object) : null;
        }

    }
}
